﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TextMIS
{
    public partial class frmPrint2 : Form
    {
        public frmPrint2()
        {
            InitializeComponent();
        }

        private int findPlace = 0; 

        private void frmPrint2_Load(object sender, EventArgs e)
        {

        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (this.txtSearch.Text != "")
            {

                frmPrint mainform = (frmPrint)this.Owner;
                
                if (mainform.richTextBox1.Text.Length > 0)
                {
                    if ((this.findPlace = mainform.richTextBox1.Text.IndexOf(this.txtSearch.Text, this.findPlace)) == -1)
                    {

                        MessageBox.Show("没有找到!");

                        this.findPlace = 0;

                    }

                    else
                    {
                        mainform.richTextBox1.Select(this.findPlace, this.txtSearch.Text.Length);

                        this.findPlace = this.findPlace + this.txtSearch.Text.Length;

                        mainform.Activate();

                    }

                }

            } 
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {

            this.Hide();

            this.Owner.Show(); 
        }
    }
}
